clear all

// SET MACROS
global Input  "Y:/limited/Michigan_CTE/funding_change/data_derived/imported"
global Output "Y:/limited/Michigan_CTE/funding_change/data_derived"

// LOAD DATA
use $Input/nsc_enrollment.dta

// RENAME VARIABLES
rename ric student
rename year grad_year

// CLEAN DATA

// Postsecondary enrollment
bys student (grad_year): gen two_yr  = (two_yr_summer[_n]  == 1 | two_yr_fall[_n]  == 1 | two_yr_spring[_n+1]  == 1)
bys student (grad_year): gen four_yr = (four_yr_summer[_n] == 1 | four_yr_fall[_n] == 1 | four_yr_spring[_n+1] == 1)
bys student (grad_year): gen public  = (public_summer[_n]  == 1 | public_fall[_n]  == 1 | public_spring[_n+1]  == 1)
bys student (grad_year): gen private = (private_summer[_n] == 1 | private_fall[_n] == 1 | private_spring[_n+1] == 1)

egen any_college = rowmax(two_yr four_yr)

gen two_yr_public   = two_yr  == 1 & public  == 1
gen two_yr_private  = two_yr  == 1 & private == 1
gen four_yr_public  = four_yr == 1 & public  == 1
gen four_yr_private = four_yr == 1 & private == 1

// KEEP VARIABLES
keep student grad_year two_yr four_yr public private any_college two_yr_public two_yr_private ///
  four_yr_public four_yr_private

// ORDER VARIABLES
order student grad_year any_college two_yr four_yr public private two_yr_public two_yr_private ///
  four_yr_public four_yr_private

// VARIABLE LABELS
label var grad_year "High school graduation year"
label var any_college "Attended any college within one-year of high school graduation"
label var two_yr "Attended two-year college within one-year of high school graduation"
label var four_yr "Attended four-year college within one-year of high school graduation"
label var public "Attended public college within one-year of high school graduation"
label var private "Attended private college within one-year of high school graduation"
label var two_yr_public "Attended two-year public college within one-year of high school graduation"
label var two_yr_private "Attended two-year private college within one-year of high school graduation"
label var four_yr_public "Attended four-year public college within one-year of high school graduation"
label var four_yr_private "Attended four-year private college within one-year of high school graduation"

// SORT & SAVE
sort student grad_year
compress
save $Output/nsc_enrollment.dta, replace
